Exceptions are known events in an application that interrupt its expected operation. For example, an application may display an error dialog box if a user does not enter a username or password. If the error is displayed during playback, the script fails unless it contains steps to handle this behavior.
To handle exceptions, record a script that captures the exception. Add the WaitForExists statement to the script to determine if the exception occurs and use conditional statements to indicate how to handle the exceptions you want to ignore. See WaitForExists and Conditional statements.
In the following example, the login button is clicked before any user credentials are entered and an error dialog box is displayed. The WaitForExists statement is used to determine if the error is displayed and assigns true or false to the LoginError variable based on the result. The If statement is used to instruct QA Wizard Pro to click the OK button in the error dialog box if the LoginError variable value is true and continue playback with the next script step.
Window("ACME Bank").Button("Login").Click()
LoginError = Window("EnterUsernamePassword").WaitForExists(5000)
If LoginError = "True" Then
Window("EnterUsernamePassword").Button("OK").Click()
End If
Window("ACME Bank").EditBox("editbox1").SetText("Guest")
Window("ACME Bank").EditBox("editbox2").SetText("SoloBug")
Window("ACME Bank").Button("Login").Click()